﻿using D20.Entities.Items;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System;

namespace D20.UnitTests.Characters
{
    
    
    /// <summary>
    ///This is a test class for ContainerTest and is intended
    ///to contain all ContainerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ContainerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Contents
        ///</summary>
        [TestMethod()]
        [DeploymentItem("D20.dll")]
        public void ContentsTest()
        {
            Container target = new Container();
            Item item = new Item();
            item.Identity.Name = "LOLWUT";
            target.Contents.AddItem(item);

            Assert.IsTrue(target.Contents.Contents.Contains(item));
        }

        /// <summary>
        ///A test for Container Constructor
        ///</summary>
        [TestMethod()]
        public void ContainerConstructorTest4()
        {
            IEnumerable<Item> contents = new List<Item>();
            Container target = new Container(contents);
        }

        /// <summary>
        ///A test for Container Constructor
        ///</summary>
        [TestMethod()]
        public void ContainerConstructorTest3()
        {
            Container target = new Container();
            Assert.IsNotNull(target.Contents);
        }

        /// <summary>
        ///A test for Container Constructor
        ///</summary>
        [TestMethod()]
        public void ContainerConstructorTest2()
        {
            IEnumerable<Item> contents = new List<Item>() { new Item(), new Item() };
            int capacity = 5;
            Container target = new Container(contents, capacity);
            foreach (Item item in contents)
            {
                Assert.IsTrue(target.Contents.Contents.Contains(item));
            }
        }

        /// <summary>
        ///A test for Container Constructor
        ///</summary>
        [TestMethod()]
        public void ContainerConstructorTest1()
        {
            bool thrown = false;
            Inventory inventory = null;
            int capacity = 0;
            try
            {                
                Container target = new Container(inventory, capacity);
            }
            catch (NullReferenceException)
            {
                thrown = true;
            }
            Assert.IsTrue(thrown);
            
        }

        /// <summary>
        ///A test for Container Constructor
        ///</summary>
        [TestMethod()]
        public void ContainerConstructorTest()
        {
            bool thrown = false;
            Inventory inventory = null;
            try
            {
                Container target = new Container(inventory);
            }
            catch (NullReferenceException)
            {
                thrown = true;
            }
            Assert.IsTrue(thrown);
            
        }
    }
}
